/**
 * @file:          Config_CmdSystem.c
 * @brief:
 * @details:
 * @author:        wjh
 * @date created:  2024.01.09
 * @version:       1.0.0
 * @par copyright (c):
 *
 * @par history (desc):
 *   version:1.0.0, wjh, 2024.01.09,15:29:03
 */

/* Include Files **************************************************************/
#include "ConfigOption.h"
#include "string.h"
#include "main.h"

/* Function Declare ***********************************************************/

/* Global Variable Define *****************************************************/
void StepperMotorController_Config_CmdSystem_Param(struct StepperMotorController *self)
{
    uint16_t n = 0;

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_help, BroadcastSupport_No, "help",
                             "",//"Get all supported command",
                             "",
                             CmdFunction_help);

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_reboot, BroadcastSupport_Yes, "reboot",
                             "",//"Restart program",
                             "",\
//                              "\
// -usage e.g.\r\n\
//   1.'reboot': Restart program",
                             CmdFunction_reboot);

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_encoder_calibrate, BroadcastSupport_No, "encoder_calibrate",
                             "",//"Perform software calibration",
                             "",\
//                              "\
// -usage e.g.\r\n\
//   1.'encoder_calibrate': Start calibration",
                             CmdFunction_encoder_calibrate);

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_encoder_calibrate_official, BroadcastSupport_No, "encoder_calibrate_official",
                             "",//"Perform hardware calibration(Officially provided)",
                             "",\
//                              "\
// -usage e.g.\r\n\
//   1.'encoder_calibrate_official': Start calibration",
                             CmdFunction_encoder_calibrate_official);

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_elec_offset_calibrate, BroadcastSupport_No, "elec_offset_calibrate",
                             "",//"Find the electrical angle offset of the motor",
                             "",\
//                              "\
// -usage e.g.\r\n\
//   1.'elec_offset_calibrate': Start calibration",
                             CmdFunction_elec_offset_calibrate);

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_control, BroadcastSupport_No, "control",
                             "",//"Enable or disable the motor control",
                             "",\
//                              "\
// -usage e.g.\r\n\
//   1.'control en 0': Disable motor control\r\n\
//   2.'control en 1': Enable motor control\r\n\
//   3.'control toggle': Toggle between enable and disable",
                             CmdFunction_control);

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_sys_param, BroadcastSupport_No, "sys_param",
                             "",//"Get system param",
                             "",\
//                              "\
// -usage e.g.\r\n\
//   1.'sys_param read all': Print all system param\r\n\
//   2.'sys_param read [param_name]': Print the param named [param_name]",
                             CmdFunction_sys_param);

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_flash_param, BroadcastSupport_No, "flash_param",
                             "",//"Read, write, save or load any param saved in the flash",
                             "",\
//                              "\
// -usage e.g.\r\n\
//   1.'flash_param read all': Read specified param(flash) and print it\r\n\
//   2.'flash_param write cur.ki 200': Write a value into specified param(flash)\r\n\
//   3.'flash_param save all': Save specified param(system) into flash\r\n\
//   4.'flash_param load all': Load specified param(flash) into system\r\n\
//   5.'flash_param reset': Reset all param to default value\r\n\
//   6.'flash_param check': check if the flash_checksum is correct",
                             CmdFunction_flash_param);

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_get, BroadcastSupport_No, "get",
                             "",//"Get any of the param supported by the system",
                             "",\
//                              "\
// -usage e.g.\r\n\
//   1.'get [param_name]': Print the value of the specified param\r\n\
// support param:\r\n\
//  pulse\r\n\
//  pos_fdb\r\n\
//  spd_fdb\r\n\
//  idiq_fdb\r\n\
//  pos_ref\r\n\
//  spd_ref\r\n\
//  idiq_ref\r\n\
//  uduq_ref\r\n\
//  all_cmd\r\n\
//  ialphaibeta_fdb\r\n\
//  uduq\r\n\
//  encoder_fdb\r\n\
//  singleturn\r\n\
//  adc\r\n\
//  phase_order\r\n\
//  iqfdf_before_u\r\n\
//  idiq_feedforward\r\n\
//  uduq_feedforward\r\n\
//  foc.theta\r\n\
//  fwc.out_iq_ref\r\n\
//  iq_loop_pid.in_ref\r\n\
//  spd_loop_pid.ref\r\n\
//  spd_loop_pid.out\r\n\
//  spd_feedforward\r\n\
//  leso\r\n\
//  fwc\r\n\
//  mech_offset\r\n\
//  steps\r\n\
//  stall_is_trigger\r\n\
//  power\r\n\
//  temp\r\n\
//  adc_ref\r\n\
//  485_data_info\r\n",
                             CmdFunction_get);

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_logger, BroadcastSupport_No, "logger",
                             "",//"Logger operation",
                             "",\
//                              "\
// -usage e.g.\r\n\
//   1.'logger en 1': Enable logger(0 for disable)\r\n\
//   2.'logger continuous_mode 1': Enable continuous send mode(0 for single mode)\r\n\
//   3.'logger trigger 1': Start to send log(0 for stop)",
                             CmdFunction_logger);

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_ripple_cal, BroadcastSupport_No, "ripple_cal",
                             "",//"Motor torque ripple calibration",
                             "",\
//                              "\
// -usage e.g.\r\n\
//   1.'ripple_cal': Motor torque ripple calibration",
                             CmdFunction_ripple_cal);

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_boot, BroadcastSupport_Yes, "boot",
                             "",//"Enter boot mode(used in OTA)",
                             "",\
//                              "\
// -usage e.g.\r\n\
//   1.'boot': Enter boot mode(used in OTA)",
                             CmdFunction_boot);

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_protection, BroadcastSupport_No, "protection",
                             "",//"Protection control",
                             "",\
//                              "\
// -usage e.g.\r\n\
//   1.'protection en 0': Disable protection check(1 for enable)\r\n\
//   2.'protection report 0': Disable protection report(1 for enable)\r\n\
//   3.'protection reset': Reset protection flag\r\n\
//   4.'protection err_code_backup': Print err code saved in flash, same for 'warn_code'\r\n\
//   5.'protection err_code': Print err code of system, same for 'warn_code_sys'",
                             CmdFunction_protection);

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_SystemId_RL, BroadcastSupport_No, "systemid",
                             "",//"System param identification",
                             "",\
//                              "\
// -usage e.g.\r\n\
//   1.'systemid RL [A | B]': Identify RL param. eg. A for A phase.\r\n\
//   2.'systemid RL ALL [0 | 1]': Identify RL param of all phase, param 1 mean save into flash after identify",
                             CmdFunction_systemid);

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_rs485_addr, BroadcastSupport_Yes, "rs485_addr",
                             "",//"Set or get the rs485 addr to the level of dir(for higher bit) and step(for lower bit)",
                             "",\
//                              "\
// -usage e.g.\r\n\
//   1.'rs485_addr set': Set addr\r\n\
//   1.'rs485_addr get': Read addr",
                             CmdFunction_rs485_addr);

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_version, BroadcastSupport_No, "version",
                             "",//"Print fireware(or cmd system or protection) version and release date",
                             "",\
//                              "\
// -usage e.g.\r\n\
//   1.'version': Print all version\r\n\
//   2.'version fireware': Print fireware version\r\n\
//   3.'version cmd_system': Print cmd_system version\r\n\
//   4.'version protection': Print protection version\r\n\
//   5.'version flash_param': Print flash_param version\r\n\
//   6.'version logger': Print logger version",
                             CmdFunction_version);

    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_control_loop, BroadcastSupport_No, "control_loop",
                             "",//"Change control mode",
                             "",\
//                              "\
// -usage e.g.\r\n\
//   1.'control_loop mode [x]': Change control mode to x. Where x can be: uduqloop_elec_angle_free, uduqloop, curloop, spdloop, posloop\r\n\
//   2.'control_loop set [x] [y]': Set loop input x to y. Where x can be: elecangle, uduq, idiqref, spdref, posref. And y can be a value\r\n\
//   3.'control_loop add [x] [y]': Set loop input x to y. Where x can be: elecangle, uduq, idiqref, spdref, posref. And y can be a value",
                             CmdFunction_control_loop);
                             
    self->RegisterCmdToTable(self, n++, FunctionCmdCode1st_emergency_pin_mode, BroadcastSupport_No, "emergency_pin_mode",
                             "",
                             "",
                             CmdFunction_emergency_pin_mode);
}
